package file.day9_16;

import java.io.File;
import java.io.FileFilter;

public class ListFilesDemo2 {
    public static void main(String[] args) {
        FileFilter filter = new FileFilter() {
            public boolean accept(File file) {
                String fileName = file.getName();
                return fileName.contains("e");
            }
        };
        File dir = new File(".");
        if(dir.isDirectory()){
            File[] subs = dir.listFiles(filter);
            System.out.println("共获取子项"+subs.length+"个");
            for (int i = 0; i < subs.length; i++) {
                System.out.println(subs[i].getName());
            }
        }
    }
}
